package com.imoblife.brainwavestus.user;


import android.app.Activity;
import android.view.View;
import android.widget.CheckBox;

import com.imoblife.brainwavestus.customview.DisplayPrewWindows;
import com.imoblife.brainwavestus.interfaces.IUserAction;
import com.imoblife.brainwavestus.product.Product;
import com.imoblife.brainwavestus.product.ProductInfo;
import com.imoblife.brainwavestus.util.MediaUtil;

public class ActionAudition implements IUserAction {
	
	private Activity mActivity;
	private CheckBox mCb;
	@Override
	public boolean act(Product product) {
		
		if ((mActivity != null) && MediaUtil.checkPlay(mActivity)) {
			
			if(mCb != null) {
				
				mCb.setChecked(false);
			}
			
			return false;
		}
		
		ProductInfo info = product.getProductInfo();
		
		new DisplayPrewWindows(
				mCb, 
				mActivity, 
				info.getName(),
				info.getTitle());
		
		return true;
	}

	@Override
	public void setView(View v) {
		
		mCb = (CheckBox)v;
	}

	@Override
	public void setActivity(Activity activity) {
		
		mActivity = activity;
	}
	
}
